home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / talinasm.lha / thinbevel.asm < prev    next >
Encoding:
Assembly Source File  |  1992-03-14  |  3.7 KB  |  144 lines

  1. * ============================================================================ *
  2. *    ThinBevel: Draws a bevel box, given a rectangle and colors.
  3. *
  4. *            ThinBevel(rp, ibox, ulpen, lrpen);
  5. *                       a1  a0    d0     d1
  6. *
  7. *    This function uses PolyDraw to quickly render a bevel box. The horizontal
  8. *    thickness of the vertical lines (1) and the vertical thickness of the
  9. *    horizontal lines (1) has been hard-coded for speed.
  10. * ============================================================================ *
  11.  
  12.             include        "exec/types.i"
  13.             include        "intuition/intuition.i"
  14.             include        "macros.i"
  15.  
  16.             SECTION    quickbevel.asm,CODE
  17.  
  18.             far            data
  19.  
  20.             xdef        _ThinBevel,ThinBevel
  21.  
  22.             xref        _LVOSetAPen,_LVOMove,_LVOPolyDraw,_GfxBase
  23.  
  24. qregs        reg            d2-d7/a2/a6
  25.  
  26. _ThinBevel:
  27.             move.l        4(sp),a1                ; RastPort
  28.             move.l        8(sp),a0                ; IBox
  29.             move.l        12(sp),d0                ; upper left pen
  30.             move.l        16(sp),d1                ; lower left pen
  31. ThinBevel:
  32.             movem.l        qregs,-(sp)
  33.             move.l        d1,d2                    ; d2 <-- lrpen
  34.             move.l        a1,a2                    ; a2 <-- copy of RP
  35.             move.l        _GfxBase,a6                ; a6 register
  36.  
  37.             moveq        #0,d4                    ; clear upper half of regs
  38.             moveq        #0,d5
  39.             moveq        #0,d6
  40.             moveq        #0,d7
  41.             movem.w        (a0),d4/d5/d6/d7        ; d4 <-- ibox_Left
  42.                                                 ; d5 <-- ibox_Top
  43.                                                 ; d6 <-- ibox_Width
  44.                                                 ; d7 <-- ibox_Height
  45.             add.w        d4,d6                    ; d6 <-- right
  46.             add.w        d5,d7                    ; d7 <-- bottom
  47.             subq.w        #1,d6                    ; d6 <-- left - 1
  48.             subq.w        #1,d7                    ; d7 <-- bottom - 1
  49.  
  50. ;---------- draw upper left part
  51.  
  52.             move.w        d5,-(sp)                ; coords[7] (y) = TOP
  53.             subq.w        #1,d6                    ; subtract 1 from RIGHT
  54.             move.w        d6,-(sp)                ; coords[6] (x) = RIGHT-1
  55.  
  56.             move.w        d5,-(sp)                ; coords[5] (y) = TOP
  57.             move.w        d4,-(sp)                ; coords[4] (x) = LEFT
  58.  
  59. ;            move.l        d0,d0                    ; upper left pen color
  60.             move.l        a2,a1                    ; a1 <-- rp
  61.             jsr            _LVOSetAPen(a6)            ; set it
  62.  
  63.             move.l        d4,d0                    ; d0 <-- LEFT
  64.             move.l        d7,d1                    ; d1 <-- BOTTOM
  65.             subq.w        #1,d1                    ; d1 <-- BOTTOM-1
  66.             move.l        a2,a1                    ; a1 <-- rp
  67.             jsr            _LVOMove(a6)            ; Move to cursor coords
  68.  
  69.             moveq        #2,d0                    ; draw 4 points
  70.             move.l        sp,a0                    ; address of coords
  71.             move.l        a2,a1                    ; a1 <-- rp
  72.             jsr            _LVOPolyDraw(a6)        ; draw the line
  73.  
  74.             lea            8(sp),sp
  75.  
  76. ;---------- draw lower right part
  77.  
  78.             addq.w        #1,d6                    ; d6 <-- RIGHT (fix from before)
  79.  
  80.             move.w        d7,-(sp)                ; coords[7] (y) = BOTTOM
  81.             move.w        d4,-(sp)                ; coords[6] (x) = LEFT + 1
  82.  
  83.             move.w        d7,-(sp)                ; coords[5] (y) = BOTTOM
  84.             move.w        d6,-(sp)                ; coords[4] (x) = RIGHT
  85.  
  86.             move.l        d2,d0                    ; lower right pen color
  87.             move.l        a2,a1                    ; a1 <-- rp
  88.             jsr            _LVOSetAPen(a6)            ; set it
  89.  
  90.             move.l        d6,d0                    ; d0 <-- RIGHT
  91.             move.l        d5,d1                    ; d1 <-- TOP
  92.             addq.w        #1,d1                    ; d1 <-- TOP + 1
  93.             move.l        a2,a1                    ; a1 <-- rp
  94.             jsr            _LVOMove(a6)            ; Move to cursor coords
  95.  
  96.             moveq        #2,d0                    ; draw 4 points
  97.             move.l        sp,a0                    ; address of coords
  98.             move.l        a2,a1                    ; a1 <-- rp
  99.             jsr            _LVOPolyDraw(a6)        ; draw the line
  100.  
  101.             lea            8(sp),sp
  102.  
  103.             movem.l        (sp)+,qregs
  104.             rts
  105.  
  106.             end
  107.  
  108. /* original C code */
  109.  
  110. ThinBevel(
  111.     struct RastPort        *rp,                    /* rastport                        */
  112.     struct IBox            *b,                        /* box to render into            */
  113.     int                    ulpen,                    /* upper-left pen                */
  114.     int                    lrpen )                    /* lower-right pen                */
  115. {    WORD                coords[8];                /* coordinates to draw             */
  116.     int                    bottom,
  117.                         right;
  118.  
  119.     bottom = b->Top    + b->Height    - 1;
  120.     right =    b->Left    + b->Width - 1;
  121.  
  122.         /* upper left edges    */
  123.  
  124.     coords[0] = b->Left;
  125.     coords[1] = b->Top;
  126.     coords[2] = right-1;
  127.     coords[3] = b->Top;
  128.  
  129.     SetAPen( rp, ulpen );
  130.     Move( rp, b->Left, bottom-1 );
  131.     PolyDraw(rp,2,coords);
  132.  
  133.         /* lower right edges    */
  134.  
  135.     coords[4] = right;
  136.     coords[5] = bottom;
  137.     coords[6] = b->Left + 1;
  138.     coords[7] = bottom;
  139.  
  140.     SetAPen( rp, lrpen );
  141.     Move( rp, right, top+1 );
  142.     PolyDraw(rp,4,coords);
  143. }
  144.